package com.helei.consumerListener;

import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Component
@RocketMQMessageListener(topic = "delay-topic-boot", consumerGroup = "group-delay")
public class ConsumerDelayListenerRocketMq implements RocketMQListener<MessageExt> {
    @Override
    public void onMessage(MessageExt messageExt) {
        LocalDateTime now = LocalDateTime.now();
        String format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(now);
        System.out.println("接收到了消息msgId:"+messageExt.getMsgId()+"," + new String(messageExt.getBody())+",结束："+format);
    }
}
